﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RightServerTab : MonoBehaviour
{
    public int id;
    public UISprite sprTag;
    public UISprite sprState;
    public UILabel labName;

    public void Init(ServerItem item)
    {
        id = item.id;
        labName.text = string.Format("{0}区  {1}",this.id, item.name);
        if (sprState)
        {
            switch (item.status)
            {
                case ServerStatus.Fluent:
                    sprState.spriteName = "ui_DL_liuchang_01";
                    break;
                case ServerStatus.Busy:
                    sprState.spriteName = "ui_DL_fanhua_01";
                    break;
                case ServerStatus.Hot:
                    sprState.spriteName = "ui_DL_huobao_01";
                    break;
                case ServerStatus.Uphold:
                    sprState.spriteName = "ui_DL_weihu_01";
                    break;
            }
        }
        if (sprTag != null)
        {
            if (item.isNew)
            {
                sprTag.spriteName = "ui_DL_new_01";
            }
            else
            {
                sprTag.gameObject.active = false;
            }
        }
        UIButton button = this.GetComponent<UIButton>();
        if (button)
        {
            button.onClick.Add(new EventDelegate(()=>
            {
                ServerListPanel.Instance.LoginServer(this.id);
            }));
        }
    }
}
